package com.treetao.union.db.service.impl;

import com.treetao.union.db.model.MallTopic;
import com.treetao.union.db.mapper.MallTopicMapper;
import com.treetao.union.db.service.MallTopicService;
import com.treetao.union.db.service.MallTopicSkuService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

/**
 * <p>
 * 主题 服务实现类
 * </p>
 *
 * @author Dev.M
 * @since 2020-04-15
 */
@Service
@Transactional(rollbackFor = Exception.class)
public class MallTopicServiceImpl extends ServiceImpl<MallTopicMapper, MallTopic> implements MallTopicService {

	@Autowired
	private MallTopicSkuService mallTopicSkuService;
	
	@Override
	public MallTopic getTopicDetailAndSkus(Long topicId) {
		MallTopic topic = getById(topicId);
		
		if(topic!=null) {
			//关联的SKU
			topic.setSkus(mallTopicSkuService.getSkus(topicId));
		}
		
		return topic;
	}

}
